package com.bonjour.work.controller.api;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.bonjour.common.core.RpcReply;
import com.bonjour.work.dto.request.user.LoginReq;
import com.bonjour.work.dto.request.user.RegistryReq;
import com.bonjour.work.service.UserService;

import javax.inject.Inject;

@RestController
@RequestMapping("/user")
public class UserLoginController {

    private UserService userService;

    @Inject
    public UserLoginController(UserService userService) {
        this.userService = userService;
    }

    /**
     * 注册
     *
     * @param registryReq
     * @return
     */
    @PostMapping("/registry")
    public RpcReply<Void> registry(@Validated @RequestBody RegistryReq registryReq) {
        return userService.registry(registryReq);
    }

    /**
     * 登录
     *
     * @param loginReq
     * @return
     */
    @PostMapping("/login")
    public RpcReply<String> login(@Validated @RequestBody LoginReq loginReq) {
        return userService.login(loginReq);
    }

}
